<?php

/**
 * This is the model class for table "accounts".
 *
 * The followings are the available columns in table 'accounts':
 * @property integer $account_id
 * @property string $name
 * @property string $password
 * @property integer $member_id
 * @property integer $site_id
 * @property integer $status
 * @property double $money_total
 * @property double $money_current
 * @property integer $ad_status
 * @property integer $grid_status
 * @property string $mac_address
 */
class Accounts extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Accounts the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'accounts';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('member_id, site_id', 'required'),
			array('member_id, site_id, status, ad_status, grid_status', 'numerical', 'integerOnly'=>true),
			array('money_total, money_current', 'numerical'),
			array('name, password', 'length', 'max'=>128),
			array('mac_address', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('account_id, name, password, member_id, site_id, status, money_total, money_current, ad_status, grid_status, mac_address', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'account_id' => 'Account',
			'name' => 'Name',
			'password' => 'Password',
			'member_id' => 'Member',
			'site_id' => 'Site',
			'status' => 'Status',
			'money_total' => 'Money Total',
			'money_current' => 'Money Current',
			'ad_status' => 'Ad Status',
			'grid_status' => 'Grid Status',
			'mac_address' => 'Mac Address',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('account_id',$this->account_id);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('password',$this->password,true);
		$criteria->compare('member_id',$this->member_id);
		$criteria->compare('site_id',$this->site_id);
		$criteria->compare('status',$this->status);
		$criteria->compare('money_total',$this->money_total);
		$criteria->compare('money_current',$this->money_current);
		$criteria->compare('ad_status',$this->ad_status);
		$criteria->compare('grid_status',$this->grid_status);
		$criteria->compare('mac_address',$this->mac_address,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}